<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="renderer" content="webkit|ie-comp|ie-stand">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <title>应用市场</title>
  <script src="../../../static/kaige/js/szload.js"></script>
  <link rel="stylesheet" href="../../../static/kaige/css/store.css">
</head>

<body>
  <div class="kaige-body">
    <div id="topbarbox"></div>
    <div id="searchbox"></div>
    <div id="product" class="productbox"></div>
    <div style="clear: both;width: 100%;height: 1px;font-size: 0;"></div>
    <div id="layuipage"></div>
  </div>

  <script>
    load_init_js(function () {
      layui.config({
        base: szoapcpath + '/static/kaige/layuiextend/'
      }).use(['kaige'], function () {
        var element = layui.element, layer = layui.layer, table = layui.table, form = layui.form, kaige = layui.kaige,
          dropdown = layui.dropdown, util = layui.util, laytpl = layui.laytpl, laypage = layui.laypage, $ = layui.$;

        var page = 1;//当前页
        var limit = 8;//每页显示的数目
        var resCount, resData;

        topbarhtml();
        // search_render();
        renderPage1();

        function topbarhtml() {
          window.is_login = szoa.getCache('yun_token');
          var content = $('#topbar').html();
          var userinfo = szoa.getCache('yun-userinfo');
          if (typeof userinfo === "string") {
            userinfo = JSON.parse(userinfo);
          }
          laytpl(content).render({
            isLogin: is_login,
            userinfo: userinfo
          }, function (reshtml) {
            renderbar(reshtml);
            var ltip = null;
            $("#cart-tag").hover(function () {
              ltip = layer.tips('购物车', '#cart-tag', {
                tips: 4
              });
            }, function () {
              layer.close(ltip);
            });
            $('#cart-tag').on('click', function (e) {
              opencart();
            });
            $('#cart-nums').html('').hide();

            $("#my-order").hover(function () {
              ltip = layer.tips('我的订单', '#my-order', {
                tips: 4
              });
            }, function () {
              layer.close(ltip);
            });
            $('#my-order').on('click', function (e) {
              myOrderTable();
            });


          });
        }

        function renderbar(html) {
          $('#topbarbox').html(html);
          $('#loginbtn').on('click', function (e) {
            loginWin();
          });
          if (!is_login) {
            setTimeout(function () {
              $('#loginbtn').click();
            }, 100);
          } else {
            // 取....
            dropdown.render({
              elem: '.demo1'
              , data: [{
                title: '个人资料'
                , id: 100
              }, {
                title: '密码修改'
                , id: 101
              }, {
                title: '退出云端'
                , id: 102
              }]
              , click: function (obj) {
                // layer.tips('点击了：' + obj.title, this.elem, { tips: [1, '#5FB878'] });
                switch (obj.id) {
                  case 100:
                    var userinfo = szoa.getCache('yun-userinfo');
                    if (typeof userinfo === "string") {
                      userinfo = JSON.parse(userinfo);
                    }
                    var uihtml = $('#userinfo_html').html();
                    laytpl(uihtml).render(userinfo, function (reshtml3) {
                      layer.open({
                        type: 1,
                        title: '个人资料',
                        area: ['550px', '450px'],
                        offset: 'rt',
                        resize: false,
                        content: reshtml3
                      });
                    });
                    break;
                  case 101:
                    var pahtml = $('#editpass_html').html();
                    var userinfo = szoa.getCache('yun-userinfo');
                    if (typeof userinfo === "string") {
                      userinfo = JSON.parse(userinfo);
                    }
                    laytpl(pahtml).render(userinfo, function (reshtml3) {
                      layer.open({
                        type: 1,
                        title: '密码修改',
                        area: ['400px', '350px'],
                        offset: 't',
                        resize: false,
                        content: reshtml3,
                        success: function (layero, index) {
                          form.on('submit(kaige_form_btn_save)', function (data) {
                            layer.alert(JSON.stringify(data.field));
                            return false;
                          });
                        }
                      });
                    });
                    break;
                  case 102:
                    layer.confirm('确认退出云端', { icon: 3, title: '退出' }, function (index) {
                      szoa.delCache('yun_token');
                      szoa.delCache('yun-userinfo');
                      location.reload();
                      layer.close(index);
                    });
                    break;
                }
              }
            });
          }
        }

        function loginWin() {
          layer.open({
            type: 2,
            title: '登录',
            area: ['350px', '350px'],
            resize: false,
            content: szoapcpath + '/pages/sys/appstore/login.html'
          });
        }

        function search_render() {
          var str = $('#search_html').html();
          laytpl(str).render({}, function (reshtml3) {
            $('#searchbox').html(reshtml3);
            $.get('/sys.appstore/apptype', function (res) {
              var apptypeselhtml = '';
              if (res.status && res.data.status) {
                apptypeselhtml = '<select name="apptype"><option value="">选择类型</option>';
                layui.each(res.data.data, function (i4, e4) {
                  apptypeselhtml += '<option value="' + e4.value + '">' + e4.name + '</option>';
                });
                apptypeselhtml += '</select>';
              }
              $('#apptype_id_select_box').html(apptypeselhtml);
              form.render(null, 'search_form3');
            });
          });
        }

        //渲染展示商品的html页面
        function renderProductHtml(data) {
          var str = $('#product_html').html();
          if (data.data.length > 0) {
            laytpl(str).render(data, function (reshtml5) {
              $('#product').html(reshtml5);
              initguomai();
            });
          }
        }

        //同步加载商品数据
        function renderProduct(page, limit) {
          $.ajax({
            async: false,
            url: '/sys.appstore/index',
            data: { "page": page, "limit": limit },
            dataType: 'json',
            success: function (res) {
              if (res.status && res.data.status) {
                resCount = res.data.count;
                resData = res.data.data;
                if (resData) {
                  if (window.is_login) {
                    //找出IDs
                    var pids = [];
                    layui.each(resData, function (i9, e9) {
                      pids.push(e9.id);
                    });
                    //取我已购买
                    $.ajax({
                      type: 'POST',
                      async: false,
                      url: '/sys.appstore/getmyapplist',
                      data: { yuntoken: szoa.getCache('yun_token'), ids: pids.join(',') },
                      dataType: 'json',
                      success: function (res1) {
                        if (res1 && res1.data && res1.data.data) {
                          layui.each(resData, function (i8, e8) {
                            layui.each(res1.data.data, function (i7, e7) {
                              if (e7.appstore_id == e8.id) {
                                resData[i8]['is_install'] = 1;
                              }
                            });
                          });
                          renderProductHtml({ data: resData, islogin: true });
                        }else{
                          layer.msg('加载错误，稍后再试');
                        }
                      }
                    });
                  } else {
                    renderProductHtml({ data: resData, islogin: false });
                  }
                }
              } else {
                layer.msg(res.msg);
              }
            }
          });
        }

        //分页的完整功能
        function renderPage1() {
          renderProduct(page, limit);
          laypage.render({
            elem: 'layuipage'
            , count: resCount
            , limit: limit
            , limits: [limit, 16]
            , curr: page
            , theme: 'blue'
            , layout: ['prev', 'page', 'next', 'limit', 'count', 'skip', 'refresh']
            , jump: function (obj, first) {
              page = obj.curr;
              limit = obj.limit;
              if (!first) {
                renderProduct(page, limit);
              }
            }
          });
        }

        //初始化购买
        function initguomai() {
          $('.goumaibtn').each(function (index, item) {
            $(item).on('click', function (e) {
              $info = $(this).parent().attr('data-info');
              $pd = JSON.parse($info);
              $str = $('#confirmOrder').html();
              laytpl($str).render($pd, function (r3html) {
                layer.open({
                  type: 1,
                  area: ['90%', '80%'],
                  content: r3html,
                  title: '<i class="layui-icon layui-icon-list"></i> 详情',
                  btn: [
                    '<i class="layui-icon layui-icon-close"></i> 关闭'
                  ],
                  resize: 0,
                  anim: 1, maxmin: 1,
                  skin: 'content-box',
                  yes: function (index, layero) {
                    layer.close(index);
                  },
                  success: function (layero, index) {
                    $('#contentBox').find('img').each(function (ii3, ee3) {
                      var iurl = $(ee3).attr('src');
                      $(ee3).attr('src', 'https://s.shengzhuoa.com' + iurl);
                    });
                  }
                });
              });
            });
          });

          $('.addcart').each(function (i5, e5) {
            $(e5).on('click', function (e) {
              $info = $(this).parent().attr('data-info');
              $pd = JSON.parse($info);
              var up = {
                product_id: $pd.id,
                yuntoken: szoa.getCache('yun_token')
              };
              toaddcart(up);
            });
          });

          $('.install').each(function (i5, e5) {
            $(e5).on('click', function (e) {
              $info = $(this).parent().attr('data-info');
              $pd = JSON.parse($info);
              var up = $pd;
              up.product_id = $pd.id;
              up.yuntoken = szoa.getCache('yun_token');
              toinstall(up);
            });
          });
        }
        //执行加入购物车
        function toaddcart(data) {
          szoa.ajax({
            type: 'POST',
            data: data,
            url: '/sys.appstore/addcart',
            success: function (res) {
              if (res && res.data) updatecartnum(res.data);
              if (res.status && res.data.status) {
                layer.msg(res.data.msg, { time: 1300 }, function () {
                  opencart();
                })
              } else {
                if (res) layer.msg(res.msg || res.data.msg);
              }
            }
          });
        }

        function toinstall(data) {
          $str = $('#install_html').html();
          laytpl($str).render(data, function (r3html) {
            layer.open({
              title: '<i class="layui-icon layui-icon-add"></i> 安装',
              type: 1,
              area: ['800px', '450px'],
              content: r3html,
              success: function (layero, index) {
                form.on('submit(install_start)', function (fdata) {
                  layer.confirm('此操作会覆盖相关文件及数据，确定安装吗？', {
                    btn: ['确定', '关闭']
                  }, function (cfindex) {
                    layer.close(cfindex);
                    var HIDE = 'layui-hide';
                    var ot1 = $('#install_start');
                    var ot2 = $('#install_disabled');

                    //对进度条进行初始化
                    element.init();
                    //模拟--为了美观1-99是模拟。但100%是真实的。
                    var n = 0, timer = setInterval(function () {
                      n = n + Math.random() * 10 | 0;
                      if (n > 99) {
                        n = 99;
                        clearInterval(timer);
                        // ot1.removeClass(HIDE);
                        // ot2.addClass(HIDE);
                      }
                      element.progress('install_prog', n + '%');
                    }, 300 + Math.random() * 1000);

                    ot1.addClass(HIDE);
                    ot2.removeClass(HIDE);

                    //实际安装
                    var iupd = { appstore_id: data.product_id, yuntoken: szoa.getCache('yun_token') };
                    szoa.ajax({
                      type: 'POST',
                      data: iupd,
                      url: '/sys.appstore/downinstall',
                      success: function (rd) {
                        if (rd.status) {
                          setTimeout(function () {
                            clearInterval(timer);
                            element.progress('install_prog', 100 + '%');
                            element.init();
                          }, 1000);
                          setTimeout(function () {
                            ot2.html(rd.msg || '安装完成');
                            //去写入本地安装表。供前端使用。
                          }, 2000);
                        }
                      }
                    });
                  });
                  return false;
                });
              }
            });
          });
        }

        //更新购物车 tag 数量
        function updatecartnum(res) {
          if (res && res.status) {
            if (res.data.count > 0) {
              $('#cart-nums').show().html(res.data.count);
            } else {
              $('#cart-nums').html('').hide();
            }
            window.cartList = res.data.list;
          }
        }

        //购物车
        function opencart() {
          layer.open({
            title: '<i class="layui-icon layui-icon-cart-simple"></i> 购物车',
            type: 1,
            area: ['400px', '550px'],
            content: '<div class="kaige-body"><table class="layui-table" id="cartTable" lay-filter="cartTable" lay-size="sm"></table></div>',
            btn: ['<i class="layui-icon layui-icon-rmb"></i> 去买单',
              '<i class="layui-icon layui-icon-fonts-clear"></i> 清空',
              '<i class="layui-icon layui-icon-close"></i> 取消'],
            skin: 'content-box',
            yes: function (index, layero) {
              toCreateOrder(index);
              return false;
            },
            btn2: function (index, layero) {
              $.post('/sys.appstore/clearcart', { yuntoken: szoa.getCache('yun_token') }, function (res) {
                if (res.status && res.data.status) {
                  updatecartnum({ status: true, data: { count: 0, list: [] } });
                  layer.close(index);
                }
                layer.msg(res && res.data && res.data.msg ? res.data.msg : res.msg);
              });
              return false;
            },
            success: function (layero, index) {
              var cartTb = table.render({
                url: '/sys.appstore/cartlist',
                where: {
                  yuntoken: szoa.getCache('yun_token')
                },
                elem: '#cartTable',
                id: 'cartTable',
                limit: 9999,
                page: false,
                method: 'post',
                height: '430px',
                totalRow: true,
                parseData: function (res) {
                  if (res.status) {
                    return {
                      "code": res.data.code, //解析接口状态
                      "msg": res.data.msg, //解析提示文本
                      "count": res.data.count, //解析数据长度
                      "data": res.data.data //解析数据列表
                    };
                  } else {
                    return {
                      "code": 1, //解析接口状态
                      "msg": res.msg, //解析提示文本
                      "count": 0, //解析数据长度
                      "data": [] //解析数据列表
                    }
                  }
                },
                cols: [[
                  { field: 'name', title: '名称', totalRowText: '合计' }
                  , { field: 'price', title: '价格', align: 'right', totalRow: true }
                  , { title: '操作', width: 80, align: 'center', toolbar: '#cartTableTrbar' }
                ]],
              });

              //单元格工具事件
              table.on('tool(cartTable)', function (obj) {
                var data = obj.data;
                if (obj.event == 'del') {
                  var tr = obj.tr;
                  var rowIndex = $(tr).attr('data-index');//当前行的索引
                  var tableData = layui.table.cache['cartTable'];
                  obj.del();
                  tableData.splice(rowIndex, 1);//删除缓存的行
                  delcart(data);
                  table.reload('cartTable', {
                    data: tableData,
                    url: null
                  });
                }
              });
            }
          });

        }

        function delcart(d, index) {
          $.post('/sys.appstore/delcart', { id: d.id, yuntoken: szoa.getCache('yun_token') }, function (res) {
            if (typeof (res.data) === "object") {
              updatecartnum(res);
            } else {
              layer.msg(typeof (res.data.msg) === "string" ? res.data.msg : res.msg);
            }
          });
        }

        //去买单
        function toCreateOrder(index) {
          $.get('/sys.appstore/createorder', { yuntoken: szoa.getCache('yun_token') }, function (res) {
            layer.close(index);
            if (res.status && res.data.status) {
              if (typeof (res.data.data.data.count) != "undefined") {
                var rd = res.data.data;
                if (rd.data.count < 1) {
                  layer.msg('购物车为空');
                  return false;
                }
              } else {
                layer.msg('购物车为空');
                return false;
              }
              $str = $('#createorder_html').html();
              laytpl($str).render(rd, function (r3html) {
                layer.open({
                  type: 1,
                  title: '买单页面',
                  area: ['400px', '600px'],
                  content: r3html,
                  btn: ['去付款', '取消'],
                  yes: function (index, layero) {
                    $('#createorder_submit').click();
                  },
                  success: function (layero, index) {
                    form.render(null, 'createorder_form');
                    switchonoff();
                    form.on('submit(createorder_submit)', function (data) {
                      var up = data.field;
                      up['yuntoken'] = szoa.getCache('yun_token');
                      szoa.ajax({
                        type: 'POST',
                        data: up,
                        url: '/sys.appstore/createorder',
                        success: function (res) {
                          if (res.status && res.data.status) {
                            var d = res.data.data;
                            if (d.pay_status == 2) { // 判断是否为0元订单,如果是0元订单直接支付成功
                              layer.msg('0元订单支付成功', { icon: 1 }, function () {
                                location.reload();
                              });
                            } else if (d.pay_status == 1) {
                              payIng(d);
                            }
                            layer.close(index);
                          } else {
                            layer.msg(typeof (res.data.msg) === "string" ? res.data.msg : res.msg);
                          }
                        }
                      });
                      return false;
                    });
                  }
                });
              });
            } else {
              layer.msg(res.data.msg);
            }
          });
        }

        function switchonoff() {
          form.on('switch(sw-coupon)', function (data) {
            if (data.elem.checked) {
              $('#coupon-inbox').removeClass('layui-hide');
            } else {
              $('#coupon-inbox').addClass('layui-hide');
            }
          });
          form.on('switch(sw-tax)', function (data) {
            if (data.elem.checked) {
              $('#tax-inbox').removeClass('layui-hide');
            } else {
              $('#tax-inbox').addClass('layui-hide');
            }
          });
          form.on('switch(sw-memo)', function (data) {
            if (data.elem.checked) {
              $('#memo-inbox').removeClass('layui-hide');
            } else {
              $('#memo-inbox').addClass('layui-hide');
            }
          });
        }

        //支付结果
        function payResult() {

        }
        //支付窗
        function payIng(d) {
          $str = $('#pay_ing_html').html();
          laytpl($str).render(d, function (r3html) {
            layer.open({
              type: 1,
              title: '支付页面',
              area: ['400px', '500px'],
              content: r3html,
              btn: ['确定', '取消'],
              yes: function (index, layero) {

              },
              end: function () {
                window.clearTimeout(window.jtwxpayresult);
              },
              success: function (layero, index) {
                payReqult(d.id, 1, index);
                element.on('tab(paycodetab)', function (data) {
                  switch (data.index) {
                    case 0:
                      payReqult(d.id, 1, index);
                      break;
                    case 1:
                      payReqult(d.id, 2, index);
                      break;
                  }
                });
              }
            });
          });
        }

        function payReqult(order_id, paycode, index) {
          $.post('/sys.appstore/payqrcode', {
            order_id: order_id,
            paycode: paycode,
            yuntoken: szoa.getCache('yun_token')
          }, function (res) {
            if (res.status && res.data.status) {
              var d = res.data.data;
              if (d.code == 'wechatpay') {
                $('#wechatpay_img').attr('src', d.qrcode_img);
              } else if (d.code == 'alipay') {
                $('#alipay_img').attr('src', d.qrcode_img);
              }
              window.jtwxpayresult = setTimeout(function () {
                pay_jtres(order_id, paycode, index);
              }, 6000);
            } else {
              layer.msg(typeof (res.data.msg) === "string" ? res.data.msg : res.msg);
            }
          });
        }

        //监听支付结果
        function pay_jtres(order_id, paycode, index) {
          $.post('/sys.appstore/scanpayresult', {
            order_id: order_id,
            yuntoken: szoa.getCache('yun_token')
          }, function (res) {
            if (res.status) {
              var d = res.data;
              if (d.status) {
                layer.msg(d.msg);
                layer.close(index);
              } else {
                if (d.end) {
                  window.clearTimeout(window.jtwxpayresult);
                  layer.msg('支付失败');
                  layer.close(index);
                } else {
                  window.jtwxpayresult = setTimeout(function () {
                    pay_jtres(order_id, paycode, index);
                  }, 6000);
                }
              }
            } else {
              layer.msg(res.msg);
            }
          });
        }

        function myOrderTable() {
          layer.open({
            type: 1,
            title: '我的订单',
            area: ['800px', '450px'],
            content: '<div class="kaige-body"><table class="layui-table" id="orderTable" lay-filter="orderTable" lay-size="sm"></table></div>',
            success: function (layero, index) {
              kaige.table({
                title: '订单列表',
                elem: '#orderTable',
                url: "/sys.appstore/myorderlist",
                id: 'orderTable',
                method: 'post',
                height: '360px',
                where: {
                  yuntoken: szoa.getCache('yun_token')
                },
                parseData: function (res) {
                  if (res.status) {
                    return {
                      "code": res.data.code, //解析接口状态
                      "msg": res.data.msg, //解析提示文本
                      "count": res.data.count, //解析数据长度
                      "data": res.data.data //解析数据列表
                    };
                  } else {
                    return {
                      "code": 1, //解析接口状态
                      "msg": res.msg, //解析提示文本
                      "count": 0, //解析数据长度
                      "data": [] //解析数据列表
                    }
                  }
                },
                cols: [[
                  { field: 'order_id_k', title: '订单号', width: 180, align: 'center', fixed: 'left' },
                  { field: 'order_amount', title: '金额', width: 100, align: 'right' },
                  { field: 'create_time', title: '下单时间', width: 170, align: 'center' },
                  { field: 'status_text', title: '状态', width: 80, align: 'center' },
                  { field: 'pay_status_txt', title: '支付否', width: 90, align: 'center' },
                  {
                    title: '操作', align: 'center', width: 120, fixed: 'right', templet: function (d) {
                      var ophtml = '<a class="layui-btn layui-btn-xs layui-bg-green" lay-event="pay">支付</a>\
                      <a class="layui-btn layui-btn-xs layui-bg-orange" lay-event="cancel">取消</a>';
                      return ophtml;
                    }
                  }
                ]]
              });
              //单元格工具事件
              table.on('tool(orderTable)', function (obj) {
                var data = obj.data;
                switch (obj.event) {
                  case 'pay':
                    payIng(data);
                    break;
                  case 'cancel':

                    break;
                }

              });
            }
          });
        }


      });
    });
  </script>
  <script type="text/html" id="pay_ing_html">
    <div class="payinfo">
      <i class="layui-icon layui-icon-rmb"></i> 订单金额：￥{{ d.order_amount }}
    </div>
    <div class="layui-tab" lay-filter="paycodetab">
      <ul class="layui-tab-title">
        <li class="layui-this">微信扫码</li>
        <li>支付宝扫码</li>
      </ul>
      <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
          <img id="wechatpay_img" src="" alt="扫码支付" class="qrcodeimg" />
        </div>
        <div class="layui-tab-item">
          <img id="alipay_img" src="" alt="扫码支付" class="qrcodeimg" />
        </div>
      </div>
    </div>
  </script>
  <script type="text/html" id="pay_result_html">
    <div class="layui-bg-gray" style="padding: 30px;">
      <div class="layui-panel">
        <div style="padding: 50px 30px;">
          <i class="layui-icon layui-icon-ok-circle fs50"></i> 支付成功
        </div>
      </div>
      <div class="layui-panel">
        <div style="padding: 50px 30px;">
          <i class="layui-icon layui-icon-close-fill fs50"></i> 支付失败
        </div>
      </div> 
    </div>
  </script>

  <script type="text/html" id="createorder_html">
    <form class="layui-form kaige-body-form" style="background-color: #f7f7f7;" lay-filter="createorder_form">
      <input type="hidden" name="order_type" value="1"/>
      <div class="userbox">
        <i class="layui-icon layui-icon-user"></i>
        <span>{{ d.user.nickname || '' }}〔{{ d.user.mobile || '' }}〕</span>
      </div>
      <table class="layui-table">
        <thead>
          <tr>
            <th>名称</th>
            <th class="tdtxtright">价格</th>
          </tr>
        </thead>
        <tbody>
          {{# var total=0,ids=''; layui.each(d.data.list,function(i9,e9){ }}
          <tr>
            <td>{{ e9.name }}</td>
            <td class="tdtxtright">￥{{ e9.price }}</td>
          </tr>
          {{# total += (e9.price * 100) ; ids += ''+e9.id+',';  }); }}
          <tr>
            <td style="text-align: right;">合计：</td>
            <td style="text-align: right;">￥{{ total >0 ? (total/100).toFixed(2) : 0 }}</td>
          </tr>
        </tbody>
      </table>
      <input type="hidden" name="cart_ids" value="{{ ids.replace(/,$/gi,'') }}"/>
      <div class="yhjbox">
        <div class="layui-card">
          <div class="layui-card-header">
            <input type="checkbox" lay-filter="sw-coupon" lay-skin="switch" lay-text="优惠券|优惠券">
          </div>
          <div class="layui-card-body layui-hide" id="coupon-inbox">
            <input type="text" name="coupon_code" class="layui-input" autocomplete="off">
          </div>
        </div>
      </div>
      <div class="yhjbox">
        <div class="layui-card">
          <div class="layui-card-header">
            <input type="checkbox" lay-filter="sw-tax" lay-skin="switch" lay-text="发票|发票">
          </div>
          <div class="layui-card-body layui-hide" id="tax-inbox">
            <div class="layui-form-item">
              <label class="layui-form-label">类型</label>
              <div class="layui-input-block">
                <select name="tax_type">
                  <option value=""></option>
                  <option value="2">个人发票</option>
                  <option value="3">企业发票</option>
                </select>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">抬头</label>
              <div class="layui-input-block">
                <input type="text" name="tax_title" class="layui-input">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">税号</label>
              <div class="layui-input-block">
                <input type="text" name="tax_code" class="layui-input">
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="yhjbox">
        <div class="layui-card">
          <div class="layui-card-header">
            <input type="checkbox" lay-filter="sw-memo" lay-skin="switch" lay-text="备注|备注">
          </div>
          <div class="layui-card-body layui-hide" id="memo-inbox">
            <textarea name="memo" class="layui-textarea" style="height: 70px;"></textarea>
          </div>
        </div>
      </div>
      <button class="layui-hide" lay-submit lay-filter="createorder_submit" id="createorder_submit">提交</button>
    </form>
  </script>
  <script type="text/html" id="cartTableTrbar">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i></a>
  </script>
  <script type="text/html" id="confirmOrder">
    <form class="layui-form kaige-body-form layui-form-pane">
      <input name="id" value="{{ d.id }}" type="hidden" />
      <div class="layui-form-item">
        <label class="layui-form-label">模块名称</label>
        <div class="layui-input-block border-b3">
          <input type="text" disabled value="{{ d.name }}" class="layui-input" style="border: none;color:#333 !important;">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">价格</label>
        <div class="layui-input-block border-b3">
          <input type="text" disabled value="￥{{ d.price }}" class="layui-input" style="border: none;color:#f00 !important;">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">摘要</label>
        <div class="layui-input-block border-b3">
          <textarea  disabled class="layui-textarea" style="height: 60px;color:#333 !important;border: none;">{{ d.brief }}</textarea>
        </div>
      </div>
      {{# if(d.tree){ }}
      <div class="layui-form-item">
        <label class="layui-form-label">目录</label>
        <div class="layui-input-block border-b3" id="treeBox">
          <textarea  disabled class="layui-textarea" style="height: 320px;color:#333 !important;border: none;">{{ d.tree }}</textarea>
        </div>
      </div>
      {{# } }}
      <div class="layui-form-item">
        <label class="layui-form-label">详情</label>
        <div class="layui-input-block border-b3" id="contentBox" style="min-height: 200px;">
          <div class="kaige-body">{{- d.content }}</div>
        </div>
      </div>      
      <button class="layui-hide" lay-submit lay-filter="confirm_order_btn" id="confirm_order_btn">提交</button>
    </form>
  </script>

  <script type="text/html" id="topbar">
    <div class="layui-row topbar">
      <div class="layui-col-xs8">
        <p class="title">应用市场 <span class="fl-red"> 〔注意：安装之前请先备份好数据库，以免造成损失！！！〕</span></p>
      </div>
      <div class="layui-col-xs4">
        <div style="text-align: right;padding-right: 20px;">
         <div class="cart-tag" id="cart-tag">
          <i class="layui-icon layui-icon-cart"></i>
          <span class="layui-badge" id="cart-nums"></span>
         </div> 
         <div class="cart-tag" id="my-order">
          <i class="layui-icon layui-icon-form"></i>
         </div>
        {{# if(d.isLogin && d.userinfo){ }}
        <a href="javascript:;" class="demo1">
          {{#if(d.userinfo.avatar){ }}
          <img src="{{ d.userinfo.avatar }}" class="yunavatar"/>
          {{# } }}
          {{ d.userinfo.real_name }}
          <i class="layui-icon layui-icon-down layui-font-12"></i>
        </a>
        {{# }else{ }}
        <a href="javascript:;" id="loginbtn">登录</a>
        <a href="javascript:;" id="regbtn">注册</a>
        {{# } }}
        </div>
      </div>
    </div>
  </script>

  <script type="text/html" id="userinfo_html">
    <div class="layui-card">
      <div class="layui-card-body">
        <div class="layui-form form-info">
          <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-inline">
              <img src="{{ d.avatar || ''  }}" class="yunavatar2"/>
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">手机</label>
            <div class="layui-inline">
              {{ d.mobile || ''  }}
            </div>
          </div>
          <div class="layui-form-item {{ d.username ? '':'layui-hide' }}">
            <label class="layui-form-label">帐户</label>
            <div class="layui-inline">
              {{ d.username || ''  }}
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">站点</label>
            <div class="layui-inline">
              {{ d.domain || ''  }}
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">单位</label>
            <div class="layui-inline">
              {{ d.unit_name || ''  }}
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">起始</label>
            <div class="layui-inline">
              {{ dateFormat("yyyy-MM-dd hh:mm:ss", new Date(d.start_time * 1000)) }}
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">截止</label>
            <div class="layui-inline">
              {{ dateFormat("yyyy-MM-dd hh:mm:ss", new Date(d.end_time * 1000))  }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </script>
  <script type="text/html" id="editpass_html">
    <form class="layui-form layui-form-pane kaige-body-form" lay-filter="kaige_form_lay_filter">
      <input type="hidden" name="id" value="{{ d.uid }}" />
      <div class="layui-form-item {{ d.username ? '':'layui-hide' }}">
          <label class="layui-form-label">账号</label>
          <div class="layui-input-inline">
              <input type="text" value="{{ d.username || '' }}" disabled autocomplete="off" class="layui-input layui-disabled">
          </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">手机</label>
        <div class="layui-input-inline">
            <input type="text" name="mobile" value="{{ d.mobile || '' }}" disabled autocomplete="off" class="layui-input layui-disabled">
        </div>
      </div>
      <div class="layui-form-item">
          <label class="layui-form-label">姓名</label>
          <div class="layui-input-inline">
              <input type="text" value="{{ d.real_name || '' }}" disabled autocomplete="off" class="layui-input layui-disabled">
          </div>
      </div>
      <div class="layui-form-item">
          <label class="layui-form-label">原密码：</label>
          <div class="layui-input-inline">
              <input type="password" name="password" required lay-verify="required" placeholder="请输入当前密码" autocomplete="off" class="layui-input">
          </div>
      </div>
      <div class="layui-form-item">
          <label class="layui-form-label">新密码：</label>
          <div class="layui-input-inline">
              <input type="password" name="newPwd" required lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
          </div>
      </div>
      <div class="layui-form-item">
          <label class="layui-form-label">确认密码：</label>
          <div class="layui-input-inline">
              <input type="password" name="rePwd" required lay-verify="required" placeholder="确认新密码" autocomplete="off" class="layui-input">
          </div>
      </div>
      <div class="layui-form-item">
          <label class="layui-form-label" style="background-color:transparent;border-color: transparent;"></label>
          <div class="layui-input-inline">
              <button class="layui-btn" lay-submit="" id="kaige_form_btn_save" lay-filter="kaige_form_btn_save">提交更改</button>
          </div>
      </div>
    </form>
  </script>
  <script type="text/html" id="search_html">
    <div class="layui-row layui-form"  lay-filter="search_form3">
      <div class="layui-form-item">
        <div class="layui-input-inline" id="apptype_id_select_box" style="width: 120px;"></div>
        <div class="layui-input-inline" style="width: 120px;">
          <select name="is_payed">
            <option value="">购买否</option>
            <option value="1">已购买</option>
            <option value="2">未购买</option>
          </select>
        </div>
        <div class="layui-input-inline" style="width: 120px;">
          <select name="is_payed">
            <option value="">安装否</option>
            <option value="1">已安装</option>
            <option value="2">未安装</option>
          </select>
        </div>
        <div class="layui-input-inline">
          <input type="text" name="name" placeholder="名称" autocomplete="off" class="layui-input">
        </div>
        <button class="layui-btn layui-btn-radius" lay-submit lay-filter="search_submit"><i class="layui-icon layui-icon-search"></i> 提交</button>
      </div>
    </div>
  </script>
  <script type="text/html" id="product_html">
    <div class="layui-row layui-col-space10">
    {{# var row = 4;layui.each(d.data,function(i9,e9){ }}
      {{# if(i9>0 && i9%4 == 0){ row=4; }}
        </div><div class="layui-row layui-col-space10">
      {{# }; }}
      <div class="layui-col-md3 ">
        <div class="layui-form layui-form-pane pubox">
          {{# if(e9.is_install ==1){ }}
          <div class="box-con"><div class="box-text">已安装</div></div>
          {{# } }}
          <div class="layui-form-item pximg"><img src="{{ e9.cover }}" class="pimg" alt="{{e9.name}}"/></div>
          <div class="layui-form-item">
            <label class="layui-form-label l60">名称</label>
            <div class="layui-input-block h36">{{ e9.name }}</div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label l60">价格</label>
            <div class="layui-input-block h36 fl-red">￥{{ e9.price }}</div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label l60">安装量</label>
            <div class="layui-input-block h36">{{ e9.sales }}</div>
          </div>
          <div class="layui-form-item guomai" data-info="{{ JSON.stringify(e9) }}">
            {{# if(e9.is_install !=1){ }}
            <button type="button" class="layui-btn layui-btn-sm bbb layui-bg-green addcart"><i class="layui-icon layui-icon-cart-simple"></i> 加入</button>
            {{# }else{ }}
            <button type="button" class="layui-btn layui-btn-sm bbb layui-bg-blue install"><i class="layui-icon layui-icon-download-circle"></i> 安装</button>
            {{# } }}
            <button type="button" class="layui-btn layui-btn-sm bbb layui-bg-orange goumaibtn"><i class="layui-icon layui-icon-list"></i> 详情</button>
          </div>
        </div>
      </div>
    {{# row--; }); }}
    {{# if(row>0){ for(var i=0;i<row;i++){ }}
      <div class="layui-col-md3"></div>
    {{# };}; }}
    </div>
  </script>

  <script type="text/html" id="install_html">
    <form class="layui-form installbox">
      <div class="layui-form-item">
        <label class="layui-form-label">模块名称</label>
        <div class="layui-form-mid layui-word-aux inline-w">{{ d.name || '' }}</div>
        <label class="layui-form-label">安装包版本</label>
        <div class="layui-form-mid layui-word-aux inline-w">{{ d.version || '' }}</div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">安装包大小</label>
        <div class="layui-form-mid layui-word-aux inline-w">{{ d.filesize || '' }}</div>
        <label class="layui-form-label">是否安装过</label>
        <div class="layui-form-mid layui-word-aux inline-w">{{ d.is_install==1 ?'安装过':'未安装' }}</div>
      </div>
      <blockquote class="layui-elem-quote layui-text" style="color: #f00;">
        注意：安装前请备份好本地数据、数据库！！！
      </blockquote>
      <div class="layui-form-item">
        <label class="layui-form-label">安装进度</label>
        <div class="layui-input-inline" style="width: 500px; padding-top: 10px;">
          <div class="layui-progress layui-progress-big" lay-showpercent="true" lay-filter="install_prog">
            <div class="layui-progress-bar layui-bg-red" lay-percent="0%"></div>
          </div>
        </div>
      </div>      
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button type="submit" class="layui-btn" lay-submit="" id="install_start" lay-filter="install_start">{{ d.is_update==1 ?'更新覆盖安装':'覆盖安装' }}</button>
          <button type="button" class="layui-btn layui-bg-gray layui-hide" id="install_disabled">正在安装</button>
        </div>
      </div>
    </form>
  </script>
</body>

</html>